import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export default{
    //选择框----获取所有用户
    getUserList(page_num,page_size){
        return request({
            url:`/user/list?page_num=${page_num}&page_size=${page_size}`,
            method:'GET',
            headers:{
                'Authorization':getToken()
            }
        })
    },

    //获取用户健康档案
    getHealthData(user_id){
        return request({
            url:`/manage/uid?user_id=${user_id}`,
            method:'GET',
            headers:{
                'Authorization':getToken()
            }
        })
    },

    //根据档案ID查找档案
    getMachineById(health_record_id){
        return request({
            url:`/manage?health_record_id=${health_record_id}`,
            method:'GET',
            headers:{
                'Authorization':getToken()
            }
        })
    },

    //添加/编辑档案
    addOrEditMachine(machine_form){
        if(machine_form.health_record_id){
            return request({
                url:`/manage`,
                method:'POST',
                data:machine_form, 
                headers: {
                    'Authorization':getToken()
                }});
          }
          else{
            return request({
                url:`/manage`,
                method:'POST',
                data:machine_form, 
                headers: {
                    'Authorization':getToken()
                }});
          }
    },

    //删除档案
    delMachine(health_record_id){
        return request({
            url:`/manage?health_record_id=${health_record_id}`,
            method:'DELETE',
            headers:{
                'Authorization':getToken()
            }
        })
    },

    //添加（更新）目标
    addOrEditTarget(target_form){
        return request({
            url:`/manage/target`,
            method:'POST',
            data:target_form, 
            headers: {
                'Authorization':getToken()
            }
        });
    },

    //删除目标
    delTarget(user_id){
        return request({
            url:`/manage/target?user_id=${user_id}`,
            method:'DELETE',
            headers:{
                'Authorization':getToken()
            }
        })
    }
}